<?php
	$id = $_POST["id"];
	$pwd = $_POST["pwd"];
	
	$link = mysqli_connect('localhost', 'root', '');
	
	if (mysqli_connect_errno()) {
		echo 'No se pudo conectar a mysql';
		exit;
	}
	
	$sql = "USE web_db";
	$resultado = mysqli_query($link,$sql);
	
	$sql = "SELECT * FROM staff
			WHERE id='$id' AND pwd='$pwd'";
	$resultado = mysqli_query($link,$sql);
	session_start();
	
	if(!$resultado){
		echo "User or pwd incorrect";
		exit;
	}
	//$user = mysqli_fetch_fields($resultado);
	$user = $resultado->fetch_array(MYSQLI_NUM);
	echo "User found";
	echo "<br>";
	echo "Name: {$user[2]} {$user[3]}";
	
	$_SESSION['id']=$id;
	$_SESSION['pwd']=$pwd;
	$_SESSION['vorname']=$user[2];
	$_SESSION['name']=$user[3];
	$_SESSION['b_date']=$user[4];
	$_SESSION['location']=$user[8];
	$_SESSION['workstation']=$user[7];

	//Array necesario para showpilots.php y missions.php
	$_SESSION['pilots_list'] = array();

	header("location:index.php");
?>

asd